Skip to content

Fixed Playing and Pausing when in mode internet radio#11

Merged
wlcrs merged 3 commits intozhelev:masterfrom
SpeedyGoneZales:master
Mar 23, 2026
Merged

Fixed Playing and Pausing when in mode internet radio#11
wlcrs merged 3 commits intozhelev:masterfrom
SpeedyGoneZales:master

Conversation

@SpeedyGoneZales
Copy link
Copy Markdown
Contributor

When in mode Internet Radio, playing and stopping a stream is achieved running http://<IP>/fsapi/SET/netRemote.play.control?pin=1234&value=0, whereas in other modes value is 1 for Play and 2 for Pause.

This pull request checks which mode the radio is in, and send 0 (aka STOP) when in Internet radio mode.

@wlcrs
Copy link
Copy Markdown
Collaborator

wlcrs commented Mar 18, 2026

pausing and stopping is not the same. Please remove the override in the pause function and add a dedicated stop function instead.

please don't change the forward/rewind functions. They function as desired: they raise an error when the radio is in an invalid mode.

@SpeedyGoneZales
Copy link
Copy Markdown
Contributor Author

@wlcrs I can't get your suggestions working.
The button on the UI is an interactive play/pause button (both on HA and Undok), how are you suggesting to make the button call stop without the override?
Forward/rewind is a similar story - the buttons are on the UI and throw an exception right in HA when pressed.
It would of course be better to remove the forward/rewind buttons depending on the mode - not sure how that would be done and still be compliant with the media player entity?

@wlcrs
Copy link
Copy Markdown
Collaborator

wlcrs commented Mar 22, 2026

All your questions here are not relevant to the code changes required in this library. So please apply the requested changes if you want me to merge this PR.

To answer your HA question: we'll need to add a dynamic "supported_features" property.

Cfr. this AI-generated example:

from homeassistant.components.media_player import (
    MediaPlayerEntity, 
    MediaPlayerEntityFeature
)

class MyDynamicPlayer(MediaPlayerEntity):
    def __init__(self):
        self._is_streaming_live = False

    @property
    def supported_features(self) -> MediaPlayerEntityFeature:
        # Base features every device has
        features = MediaPlayerEntityFeature.PLAY | MediaPlayerEntityFeature.PAUSE
        
        # Dynamically add SEEK only if not a live stream
        if not self._is_streaming_live:
            features |= MediaPlayerEntityFeature.SEEK
            
        return features

    async def async_update_stream_type(self, is_live):
        """Call this when your device state changes."""
        self._is_streaming_live = is_live
        # THIS IS THE SYNC CALL: It tells HA to re-read 'supported_features'
        self.async_write_ha_state()

Copy link
Copy Markdown
Contributor Author

@SpeedyGoneZales SpeedyGoneZales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added stop method and test for stop method

@wlcrs wlcrs merged commit f3d6ca1 into zhelev:master Mar 23, 2026
@wlcrs
Copy link
Copy Markdown
Collaborator

wlcrs commented Apr 3, 2026

Hi @SpeedyGoneZales ,

Your changes have been released today. I'm looking into updating the HA integration now (cfr. wlcrs/home-assistant-core@b8acce8) .

However, when testing the start/stop when in Internetradio-mode, I notice that trying to start the stream again with http://192.168.1.183/fsapi/SET/netRemote.play.control?pin=1234&value=2 does not work. However, http://192.168.1.183/fsapi/SET/netRemote.play.control?pin=1234&value=0 does work for me.

This is strange, as 2 is generally used for PLAY and 0 for STOP. Can you verify if you see the same behavior on your device? Ie. both starting and stopping happens with the same value '0' ?

@SpeedyGoneZales
Copy link
Copy Markdown
Contributor Author

Hi @SpeedyGoneZales ,

Your changes have been released today. I'm looking into updating the HA integration now (cfr. wlcrs/home-assistant-core@b8acce8) .

However, when testing the start/stop when in Internetradio-mode, I notice that trying to start the stream again with http://192.168.1.183/fsapi/SET/netRemote.play.control?pin=1234&value=2 does not work. However, http://192.168.1.183/fsapi/SET/netRemote.play.control?pin=1234&value=0 does work for me.

This is strange, as 2 is generally used for PLAY and 0 for STOP. Can you verify if you see the same behavior on your device? Ie. both starting and stopping happens with the same value '0' ?

Yes, that is exactly what misled me into trying all the things with somehow persisting the last played station.
In the end, I just had to use 0 to both stop and then start playback again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants